package work;

public class Work3 {
    public void put1(){
        for (int i = 0; i < 100; i++) {
            System.out.println(Thread.currentThread().getName()+i);
        }
    }

    public void put2(){
        for (int i = 100; i < 1000; i++) {
            System.out.println(Thread.currentThread().getName()+i);
        }
    }
}

class Put1 implements Runnable{
    private Work3 w3;

    public Put1(Work3 w3) {
        this.w3 = w3;
    }

    @Override
    public void run() {
        w3.put1();
    }
}

class Put2 implements Runnable{
    private Work3 w3;
    public Put2(Work3 w3) {
        this.w3 = w3;
    }

    @Override
    public void run() {
        w3.put2();
    }
}

class TestWork3{
    public static void main(String[] args) {
        Work3 w3 = new Work3();
        Thread t1 = new Thread(new Put1(w3),"one");
        Thread t2 = new Thread(new Put2(w3),"two");
        t1.start();
        try {
            t1.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        t2.start();
    }

}